<?php
/**
 * Description of CreateAdminModule
 * 管理员管理Module
 * @author
 */
//require_rewrite(MODULE_ROOT.'dao/UserDao.class.php');
class CreateAdminModule extends BaseModule{

    public function __construct() {
        parent::__construct();
    }

    /**
     * 管理员列表
     */
    public function AdminList($directoryId){
        if(empty($directoryId)){
            return false;
        }
        $getList=  UserDao::sqlAdminList($directoryId);
        return $getList;
    }

    /**
     * 添加管理员
     * @param array $userdata 管理员信息
     * @param str;
     */
    public function addAdminUser($userdata){
         if (is_array($userdata) && !empty($userdata)) {
            $list=UserDao::getUserList();
            foreach($list as $row){
                $username[]=$row['username'];
            }
            $u_list=UserDao::sqlAuditUser('',1);
            foreach($u_list as $val){
                $name[]=$val['username'];
            }
            if(in_array($userdata['username'],$username) || in_array($userdata['username'],$name)){
                return 1;//同名
            }
            $userdata['password']=md5($userdata['txtpassword'].ADMIN_KEY);
            $addSQL=UserDao::sqlAddAdmin($userdata);
            if($addSQL){
                return 2;
            }
            return 3;
        }
    }
    
    /**
     * 删除管理员帐号
     */
    public function delAdminUser($userid){
        if(!empty($userid)){
            return UserDao::sqlDelEnableUser($userid);
        }
    }
   
}
?>